<template>
  <div class="article-item van-hairline--bottom" @click="toArticle">
    <p
      class="title van-multi-ellipsis--l2"
      :class="{ w66: item.cover.type === 1 }"
    >
      {{ item.title }}
    </p>
    <img
      v-for="(item, index) in item.cover.images"
      :key="index"
      class="img"
      :src="item"
      alt=""
    />
    <div class="info">
      <span>{{ item.aut_name }}</span>
      <span>{{ item.comm_count }}评论</span>
      <span>{{ item.pubdate | formatTime }}</span>
      <geek-icon name="esay-close"></geek-icon>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ArticleItem',
  props: ['item'],
  methods: {
    toArticle () {
      // 基本路由传参
      // this.$router.push('/article?id=' + this.item.art_id)
      // 动态匹配路由传参
      this.$router.push('/article/' + this.item.art_id)
    }
  }
}
</script>

<style lang="less" scoped>
.article-item {
  padding: 15px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;

  .title {
    width: 100%;
    margin: 0;
    line-height: 22px;
    font-size: 16px;
    color: #333;
    margin-bottom: 8px;
    max-height: 44px;

    &.w66 {
      width: 66%;
    }
  }

  .img {
    width: 112px;
    height: 74px;
    border-radius: 4px;
    margin-bottom: 8px;
  }

  .info {
    width: 100%;
    color: #a5a6ab;
    font-size: 12px;
    position: relative;

    span {
      margin-right: 12px;
    }

    .geek-icon {
      float: right;
      font-size: 14px;
    }
  }
}
</style>
